package com.example.financeapi.controller;

import com.example.financeapi.config.annotation.AccessLimit;
import com.example.financeapi.config.annotation.PassToken;
import com.example.financeapi.config.annotation.SystemJobLog;
import com.example.financeapi.entity.FNewdebt;
import com.example.financeapi.enums.ResultEnum;
import com.example.financeapi.service.FNewdebtService;
import com.example.financeapi.entity.vo.ResultVOUtil;
import com.example.financeapi.entity.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 新债申购表(FNewdebt)表控制层
 * @author Alvin
 */
@Slf4j
@RestController
@RequestMapping("fNewdebt")
public class FNewdebtController {

    @Autowired
    private FNewdebtService fNewdebtService;

    /**
     * 查询新债发行列表
     * @param bndTrdCode 债劵代码
     * @param bndSecuSht 债劵名称
     * @param issuingState 发行状态 0即将发行 1今日发行 2已发行
     * @param psnSubDtOn 申购日期
     * @param bndLstDt 上市时间
     * @return
     */
    @PassToken
    @AccessLimit(times = 5)
    @SystemJobLog(description = "查询新债发行列表")
    @GetMapping("getFNewdebtList")
    public ResultVo getFNewdebtList(String bndTrdCode,String bndSecuSht,String issuingState,String psnSubDtOn,String bndLstDt) {
        Map<String,Object> paramMap =new HashMap<>();
        paramMap.put("bndTrdCode",bndTrdCode);
        paramMap.put("bndSecuSht",bndSecuSht);
        paramMap.put("issuingState",issuingState);
        paramMap.put("psnSubDtOn",psnSubDtOn);
        paramMap.put("bndLstDt",bndLstDt);
        try {
            List<FNewdebt> getFNewdebtList=fNewdebtService.getFNewdebtList(paramMap);
            return ResultVOUtil.success(getFNewdebtList);
        } catch (Exception e) {
            log.error("【接口：getFiveKMMapList】后台异常，e={}" + e.getMessage(), e);
            return ResultVOUtil.error(ResultEnum.PROGRAM_EXCEPTION.getMessage() + e.getMessage(), e);
        }
    }

}